<template>
  <view>
    <view class="header">
      <!-- #ifndef H5 -->
      <uni-nav-bar left-icon="back" title="个人工单" statusBar="true" :fixed="false" backgroundColor="#2C2C2C"
                   color="#fff" @clickLeft="handleBack" v-if="type == 2"></uni-nav-bar>
      <Header v-else ref="Headers" @filter="filterFuc" :tabIdx="filtIdx" :customDate="customDate" :shadow="false"
              @toNext="toNext" :myElevator="true" :filterList="filterList"></Header>
      <!-- #endif -->

      <view class="tabs">
        <view :class="['tabs-item', tabIdx == 0 ? 'act' : '']" @click="handleClickTab(0)">保养</view>
        <view :class="['tabs-item', tabIdx == 1 ? 'act' : '']" @click="handleClickTab(1)">维修</view>
        <view :class="['tabs-item', tabIdx == 2 ? 'act' : '']" @click="handleClickTab(2)">配件</view>
        <view :class="['tabs-item', tabIdx == 3 ? 'act' : '']" @click="handleClickTab(3)">事务</view>
        <view :class="['tabs-item', tabIdx == 4 ? 'act' : '']" @click="handleClickTab(4)">质检</view>
        <view :class="['tabs-item', tabIdx == 5 ? 'act' : '']" @click="handleClickTab(5)">救援</view>
      </view>
      <view class="fitlerBox">
        <view class="left">
          <!-- <input type="text" v-model="seachForm.keyword" placeholder="请输入项目/电梯关键词" @confirm="handleReSet" 																																					/> -->
          <uni-search-bar v-model="seachForm.keyword" clearButton="auto" cancelButton="none"
                          placeholder="搜索项目/电梯关键词" @blurs="handleReSet" />
          <!-- <image src="/static/images/index/search.png" mode=""></image> -->
        </view>
        <view class="right">
          <filterModel :all="false" :orderType="tabIdx" ref="filterModel" :dateOpt="dateObj" :typeForm="type"
                       :userIds="(seachForm.userList || []).join(',')" :keyword="seachForm.keyword" :csd="csd"
                       :start="seachForm.startTime" :end="seachForm.endTime" @filterd="filterd"
                       :status="seachForm.status" @showFilterChange="showFilterChange"></filterModel>
        </view>
      </view>
      <view class="line"></view>
      <scroll-view scroll-x="true" class="scroll-x">
        <view class="tabList">
          <view v-for="(item, index) in tabList"
                :class="['titleTab', tabStateIdx == index ? 'activeItem' : '']" @click="chooseTab(item, index)"
                :key="index">
            {{ item.name }}
          </view>
        </view>
      </scroll-view>
      <!-- <view class="tips" v-if="type == 2"></view> -->
    </view>
    <ui-container :scrollGoTop="scrollGoTop" @scrolltolower="scrolltolower" :isCanScroll="isCanScroll"
                  @scroll="scroll" :scrollbar="false" :headerHeight="headerHeight">
      <view class="wrap">
        <!-- 工单数 计划时间 完成时间 -->
        <view class="planTime">
          <view class="left">
            共<text>{{ total }}</text>个
          </view>
          <view class="right">
            <block v-if="![3, 4, 5].includes(tabIdx)">
              <view class="plan" @click="changePlanDateSort">
                {{ timeList[tabIdx] }}
                <view class="header-icon">
                  <text class="iconfont icon-arrow-up"
                        :style="{ color: seachForm.planDateSort == '' ? '#999999' : seachForm.planDateSort == 'asc' ? '#0091ff' : '#999999' }" />

                  <text class="iconfont icon-arrow-down"
                        :style="{ color: seachForm.planDateSort == '' ? '#999999' : seachForm.planDateSort == 'desc' ? '#0091ff' : '#999999' }" />
                </view>
              </view>
              <view class="end" v-if="tabStateIdx == tabList.length - 1" @click="changePlanFishDateSort">
                完成时间
                <view class="header-icon">
                  <text class="iconfont icon-arrow-up" :style="{

										color: seachForm.planFishDateSort == '' ? '#999999' : seachForm.planFishDateSort == 'asc' ? '#0091ff' : '#999999'
									}" />
                  <text class="iconfont icon-arrow-down" :style="{

										color: seachForm.planFishDateSort == '' ? '#999999' : seachForm.planFishDateSort == 'desc' ? '#0091ff' : '#999999'
									}" />
                </view>
              </view>
            </block>
            <block v-if="[3, 4, 5].includes(tabIdx)">
              <view class="plan" @click="changePlanDateSort">
                {{ timeList[tabIdx] }}
                <view class="header-icon">
                  <text class="iconfont icon-arrow-up"
                        :style="{ color: !seachForm.createSort ? '#999999' : seachForm.createSort == 'asc' ? '#0091ff' : '#999999' }" />

                  <text class="iconfont icon-arrow-down"
                        :style="{ color: !seachForm.createSort ? '#999999' : seachForm.createSort == 'desc' ? '#0091ff' : '#999999' }" />
                </view>
              </view>
              <view class="end" v-if="tabStateIdx == tabList.length - 1" @click="changePlanFishDateSort">
                完成时间
                <view class="header-icon">
                  <text class="iconfont icon-arrow-up" :style="{

										color: !seachForm.finishSort ? '#999999' : seachForm.finishSort == 'asc' ? '#0091ff' : '#999999'
									}" />
                  <text class="iconfont icon-arrow-down" :style="{

										color: !seachForm.finishSort ? '#999999' : seachForm.finishSort == 'desc' ? '#0091ff' : '#999999'
									}" />
                </view>
              </view>
            </block>

          </view>
        </view>
        <!-- 底部 -->
        <tk-screen-scroll :list="['保养', '维修', '配件', '事务', '质检', '救援']" @getActIdx="getActIdx" :active="tabIdx"
                          :height="135">
          <view class="none-block" v-if="!loading && total == 0">
            <view class="img">
              <image src="@/static/images/default.png"></image>
            </view>
            <view class="text">- 暂无相关数据 -</view>
          </view>
          <view class="records" :style="{ marginTop: type !== 2 ? '16rpx' : '0rpx' }">
            <!-- {{type}} -->
            <view class="records-item" v-for="(item, index) in list" :key="item.planId"
                  :style="{ marginTop: index == 0 ? 0 : '20rpx' }">
              <view class="records-item-head" @click.stop="toProjectDetail(item)">
                <view class="buildding">
                  <image src="/static/images/index/build.svg	" mode=""></image>
                  <view class="">
                    {{ item.buildingName }}
                    <uni-icons color="#999999" type="forward" v-if="type == 2"></uni-icons>
                  </view>
                </view>
                <view class="status" v-if="tabIdx == 0">
                  <image :src="statusBy[item.status].icon"></image>
                  <view :style="{ color: statusBy[item.status].color }">{{ statusBy[item.status].text
                    }}
                  </view>
                </view>
                <view class="status" v-if="tabIdx == 1">
                  <image v-if="statusWx[item.status].icon" :src="statusWx[item.status].icon"></image>
                  <view :style="{ color: statusWx[item.status].color }">{{
                      statusWx[item.status].text
                    }}
                  </view>
                </view>
                <view class="status" v-if="tabIdx == 2">
                  <image v-if="statusPj[item.status].icon" :src="statusPj[item.status].icon"></image>
                  <view :style="{ color: statusPj[item.status].color }">{{
                      statusPj[item.status].text
                    }}
                  </view>
                </view>
                <view class="status" v-if="[3, 4].includes(tabIdx)">
                  <image v-if="statusWx[item.planStatus].icon" :src="statusWx[item.planStatus].icon">
                  </image>
                  <view :style="{ color: statusWx[item.planStatus].color }">{{
                      statusWx[item.planStatus].text
                    }}
                  </view>
                </view>
                <view class="status" v-if="[5].includes(tabIdx)">
                  <image v-if="statusRescue[item.planStatus].icon"
                         :src="statusRescue[item.planStatus].icon"></image>
                  <view :style="{ color: statusRescue[item.planStatus].color }">{{
                      statusRescue[item.planStatus].text
                    }}
                  </view>
                </view>
              </view>

              <view class="records-item-content" @click.stop="toDetail(item)">
                <view class="name">
                  <text>{{ tabIdx === 5 ? (item.elevatorAddress || '电梯未知'
                  ) : item.elevatorAddress }}</text>
                  <text v-if="item.isStop == 2" class="Rtag">停梯</text>
                  <block v-if="![3, 4, 5].includes(tabIdx) && item.emerProcType == item.key">
                    <!-- <text class="Rtag" v-for="(it, i) in btnBoxList" :key="i" :style="{
                      color: it.color, borderColor: it.color,
                    }">
                      {{ it.label }}</text> -->
                    <text class="plan-turn"
                          :style="item.elevatorAddress.length > 16 ? 'display:block;' : ''"
                          v-if="item.giveStatus === 1">转派工单</text>
                  </block>
                </view>
                <view class="intro">
                  <view class="left">
                    <view class="tags" v-if="tabIdx == 0">
                      <!-- 个人工单 -->
                      <tags-component label="保养：" displayCount="6"
                                      :templateNames="item.templateNames" />
                    </view>
                    <view class="tags" v-if="tabIdx == 1">
                      <view class="lable">维修：</view>
                      <view class="tag" v-if="item.partsName">{{ sliceStr(item.partsName) }}
                        <text v-if="item.partsName && item.floorStandNames">({{
                            item.floorStandNames.replaceAll(',', '>') }})</text>
                      </view>
                      <template v-else-if="item.problemItemNames">
                        <view class="tag" v-for="tag in item.problemItemNames" :key="tag">{{ tag
                          }}
                        </view>
                      </template>
                      <view v-else>--</view>
                    </view>
                    <view class="tags" v-if="tabIdx == 2">
                      <view class="lable">配件：</view>
                      <view class="tag">配件更换</view>
                    </view>

                    <view class="labs" v-if="tabIdx == 0">
                      <view class="lab" :class="[item.overdueType === 2 ? 'yellow' : 'red']"
                            v-if="[2,3].includes(item.overdueType) && item.overdueTypeName.indexOf('逾期') != -1">
                        {{
                          item.overdueTypeName
                        }}</view>
                      <view class="lab" style="background: #fdf1e9;color: #fa6400;"
                            v-if="item.timeliness && item.timeliness.indexOf('超时') != -1">
                        {{
                          item.timeliness
                        }}</view>
                      <!-- <view class="lab" v-if="item.isDeferred === 1">延期保养</view> -->
                      <view class="lab" style="margin: 0 10rpx;"
                            v-if="item.deferType === 1 || item.deferType === 5">{{
                          item.deferType ===
                          1 ? '延期保养' : '特殊延期'
                        }}</view>
                    </view>
                    <view class="labs" v-if="tabIdx == 2">
                      <view class="lab blue">{{ sliceStr(item.parts) }}
                        <text v-if="item.parts && item.floorStandNames">({{
                            item.floorStandNames.replaceAll(',', '>') }})</text>
                      </view>
                      <view class="lab blue">数量:{{ item.num }}</view>
                    </view>
                    <block v-if="[3, 4, 5].includes(tabIdx)">
                      <view class="tags">
                        <view class="lable">{{ ["工单类型:", "工单类型:", "报警类型:"][tabIdx - 3] }}
                        </view>
                        <view class="tag noBorder">{{ ["事务工单", "质检工单", "困人"][tabIdx - 3] }}
                        </view>
                      </view>
                      <view class="tags_desc">
                        <view class="lable_tit">{{ ["任务描述:", "任务描述:", "报警备注:"][tabIdx - 3] }}
                        </view>
                        <view class="lable_desc">{{ item.planDesc }}</view>
                      </view>
                    </block>
                  </view>
                  <view class="right" @click.stop="">
                    <view v-if="item.planContentUserVos.length <= 2" class="right-member">
                      <view v-for="(user, uIdx) in item.planContentUserVos.slice(0, 2)"
                            :key="uIdx" :class="['menber']"
                            :style="{ background: !user.signInfo.isPlanStatus ? '#b9b9b9' : userinfo.nick_name === user.signUser.userName ? '#0091ff' : '#00C6C0' }">
                        <text
                            v-if="item.status == 1 || item.status == 2 || item.status == 5 || item.status == 6">
                          {{ user.userName.length > 2 ? user.userName.slice(-2) :
                            user.userName }}
                        </text>
                        <text v-else>
                          <block v-if="user.signUser">
                            {{
                              user.signUser.userName.length > 2 ?
                                  user.signUser.userName.slice(-2)
                                  : user.signUser.userName
                            }}
                          </block>
                          <block v-else>
                            {{ user.userName.length > 2 ? user.userName.slice(-2) :
                              user.userName }}
                          </block>
                        </text>
                      </view>
                      <image v-if="item.planContentUserVos.length > 2"
                             src="/static/images/down.png" />
                    </view>
                    <zb-tooltip v-else :items="item" @click.stop
                                @handchange="handchange($event, index)" placement="bottom" background="#fff"
                                :right="26" color="#333" :showIcon="false">
                      <view class="right-member">
                        <view v-for="(user, uIdx) in item.planContentUserVos.slice(0, 2)"
                              :key="uIdx" :class="['menber']"
                              :style="{ background: !user.signInfo.isPlanStatus ? '#b9b9b9' : userinfo.nick_name === user.signUser.userName ? '#0091ff' : '#00C6C0' }">
                          <text
                              v-if="item.status == 1 || item.status == 2 || item.status == 5 || item.status == 6">
                            {{ user.userName.length > 2 ? user.userName.slice(-2) :
                              user.userName }}
                          </text>
                          <text v-else>
                            <block v-if="user.signUser">
                              {{
                                user.signUser.userName.length > 2 ?
                                    user.signUser.userName.slice(-2)
                                    : user.signUser.userName
                              }}
                            </block>
                            <block v-else>
                              {{ user.userName.length > 2 ? user.userName.slice(-2) :
                                user.userName }}
                            </block>
                          </text>

                        </view>
                        <image v-if="item.planContentUserVos.length > 2"
                               :style="item.usermore ? 'transform: rotate(180deg);' : ''"
                               src="/static/images/down.png" mode=""></image>
                      </view>
                      <view class="userlist" slot="content">
                        <view v-for="(user, uIdx) in item.planContentUserVos" :key="uIdx"
                              class="userlist-item">
                          <view :class="['menber']"
                                :style="{ background: !user.signInfo.isPlanStatus ? '#b9b9b9' : userinfo.nick_name === user.signUser.userName ? '#0091ff' : '#00C6C0' }">
                            <text
                                v-if="item.status == 1 || item.status == 2 || item.status == 5 || item.status == 6">
                              {{ user.userName.length > 2 ? user.userName.slice(-2) :
                                user.userName }}
                            </text>
                            <text v-else-if="user.signUser">
                              {{
                                user.signUser.userName.length > 2 ?
                                    user.signUser.userName.slice(-2) :
                                    user.signUser.userName
                              }}
                            </text>
                          </view>
                          <view class="userlist-item-name"
                                :style="!user.signInfo.isPlanStatus ? 'color: #999999;' : 'color: #333'">
                            <text
                                v-if="item.status == 1 || item.status == 2 || item.status == 5 || item.status == 6">
                              {{ user.userName.length > 2 ? user.userName.slice(-2) :
                                user.userName }}
                            </text>
                            <text v-else>
                              <block v-if="user.signUser">
                                {{
                                  user.signUser.userName.length > 2 ?
                                      user.signUser.userName.slice(-2)
                                      : user.signUser.userName
                                }}
                              </block>
                              <block v-else>
                                {{ user.userName.length > 2 ? user.userName.slice(-2)
                                  : user.userName }}
                              </block>
                            </text>
                          </view>
                        </view>
                      </view>
                    </zb-tooltip>
                  </view>
                </view>
              </view>

							<view class="records-item-bottom" v-if="tabIdx == 0">
								<view class="">计划时间：{{ item.planDate.split(' ')[0] }}</view>
								<view style="color: #FF7505;" v-if="item.scoreStatus == 0 && item.status == 4">待评分
								</view>
								<view
									:style="{ color: item.scoreType == 1 ? '#68CA00' : item.scoreType == 2 ? '#E02020' : '#333333' }"
									v-if="item.scoreStatus == 1 && item.status == 4">已评分：<text>{{
										item.scoreType == 1 ? '有效工单' : item.scoreType == 2 ? '无效工单' : '无法判断' }}</text>
									<text v-if="item.scoreType == 1 || item.scoreType == 2">({{ item.score }}分)</text>
								</view>
								<view class="handle" v-if="showTurnBtn(item) && item.status == 1"
									@click.stop="handleMore(item, item.typeStatus, item.planId)">
									<view class="handle_btn">更多操作</view>
								</view>
							</view>
							<view class="records-item-bottom" v-if="tabIdx == 1">
								<view>报障时间：{{ item.createTime }}</view>
								<view style="color: #FF7505;" v-if="item.scoreStatus == 0 && item.status == 4">待评分
								</view>
								<view
									:style="{ color: item.scoreType == 1 ? '#68CA00' : item.scoreType == 2 ? '#E02020' : '#333333' }"
									v-if="item.scoreStatus == 1 && item.status == 4">已评分：<text>{{
										item.scoreType == 1 ? '有效工单' : item.scoreType == 2 ? '无效工单' : '无法判断' }}</text>
								</view>
							</view>
							<view class="records-item-bottom" v-if="tabIdx == 2">申请时间：{{ item.createTime }}</view>
							<view class="records-item-bottom" v-if="[3, 4, 5].includes(tabIdx)">创建时间：{{ item.createTime
							}}
							</view>
						</view>

            <view class="more" v-if="!loading && total > 0 && total <= list.length">- 已经到底了 -</view>
            <view class="more" v-if="loading">加载中..</view>
          </view>
        </tk-screen-scroll>
      </view>
      <view-top ref="viewTop" :scrollTop="scrollTop" :distance="100" @goTop="goTop"></view-top>

    </ui-container>
    <!-- 选择项目弹窗 -->
    <buidingEleCom ref="buidingEleCom" :isBuildingsShow="true" :tits="seleState == 'STATUS_IN' ? '签到提醒' : '签退提醒'"
                   :submitText="seleState == 'STATUS_IN' ? '立即签到' : '立即签退'" :seleShows="seleShows"
                   @bindClose="seleShows = false;" :seleArrs="buildingData" @selectChecd="selectChecd" />

  </view>
</template>

<script>
import UiContainer from '@/components/ui-container/ui-container';
import { getLastDates } from '@/utils/tools.js';
import { getNowTime } from '@/utils/utils.js';
// import timeSelect from '@/pages/index/components/timeSelect.vue';
import { mapState, mapActions } from 'vuex';
// import { getOrderDetailUser } from '@/apis/statistic.js';
import Header from '@/pages/index/components/header.vue';
import TkScreenScroll from '@/components/tk-screen-scroll/index';
import { orderReordBy, orderReordWx, orderReordPj, getUserWorksPlan } from '@/apis/workOrder.js';
// import filterContent from './filterContent.vue';
import filterModel from './model';
// import unipopup from '@/components/uni-popup/uni-popup.vue';
import { getMonthDate, formatTime } from '@/utils/utils.js';
import viewTop from '@/components/viewTop/viewTop.vue';
import { removeEmpty, hanleToken } from '@/utils/utils.js';
import dayjs from 'dayjs';

import buidingEleCom from './components/buidingEleCom.vue';

// 多标签组件
import tagsComponent from '@/components/tagsComponents/index';

export default {
	components: { Header, filterModel, UiContainer, TkScreenScroll, viewTop, tagsComponent, buidingEleCom },
	computed: {
		...mapState('user', ['userinfo']),
		typeTitle() {
			return ['保养', '维修', '配件'][this.tabIdx] + '工单筛选';
		},
		filterArr() {
			let arr = [];
			if (this.tabIdx == 0) {
				arr = [{ title: '申请时间', key: 'date', list: [{ name: '近7天', value: 0 }, { name: '近30天', value: 1 }, { name: '近60天', value: 2 }] }];
			}
			return arr;
		}
	},
	data() {
		return {
			// 顶部盒子高度
			headerHeight: 0,
			timeList: ['计划时间', '报障时间', '申请时间', '创建时间', '创建时间', '创建时间'],
			// 状态搜索下标
			tabStateIdx: 0,
			// 紧急程度标签
			btnBoxList: [
				{ color: '#0091FF', bgColor: '#dcf0ff', label: '较低', key: '4', },
				{ color: '#F7B500', bgColor: '#fff7e1', label: '普通', key: '3', },
				{ color: '#fa6400', bgColor: '#ffecdf', label: '紧急', key: '2', },
				{ color: '#e02020', bgColor: '#ffecec', label: '非常紧急', key: '1', },
			],
			tabList: [
				{
					name: '全部',
					status: ''
				},
				{
					name: '待开始',
					status: 1
				},
				{
					name: '进行中',
					status: 2
				},
				{
					name: '已提交',
					status: 3
				},
				{
					name: '维保签字',
					status: 5
				},
				{
					name: '已完成',
					status: 4
				}
			],
			bool: true,
			// 返回顶部
			scrollGoTop: 0,
			// 滚动距离
			scrollTop: 0,
			totalData: {
				byOrderCount: 0,
				pjOrderCount: 0,
				wxOrderCount: 0
			},
			selectTimePopup: false,
			filtIdx: 2,
			filterList: [
				{
					id: 10,
					name: '近七天'
				},
				{
					id: 11,
					name: '近30天'
				},
				{
					id: 12,
					name: '自定义'
				}
			],
			statusBy: {
				// 保养状态列表
				1: {
					text: '待开始',
					color: '#16BF99',
					icon: '/static/images/index/1.png'
				},
				2: {
					text: '进行中',
					color: '#0091ff',
					icon: '/static/images/index/2.png'
				},
				3: {
					text: '已提交',
					color: '#F7B500',
					icon: '/static/images/index/3.png'
				},
				5: {
					text: '签字完成',
					color: '#FA6400',
					icon: '/static/images/index/5.png'
				},
				4: {
					text: '已完成',
					color: '#333',
					icon: '/static/images/index/s4d.png'
				},
				6: {
					text: '已完成',
					color: '#333',
					icon: '/static/images/index/s4d.png'
				}
			},
			statusWx: {
				// 维修状态
				1: {
					text: '待开始',
					color: '#16BF99',
					icon: '/static/images/index/1.png'
				},
				2: {
					text: '待开始',
					color: '#16BF99',
					icon: '/static/images/index/1.png'
				},
				3: {
					text: '进行中',
					color: '#0091ff',
					icon: '/static/images/index/2.png'
				},

				4: {
					text: '已完成',
					color: '#333',
					icon: '/static/images/index/s4d.png',
				},
				5: {
					text: '已关闭',
					color: '#999',
					icon: '',
				},
				6: {
					text: '已驳回',
					color: '#999',
					icon: '',
				},
				7: {
					text: '已关闭',
					color: '#999',
					icon: '',
				},
			},
			statusPj: {
				// 配件状态
				5: {
					text: '待开始',
					color: '#16BF99',
					icon: '/static/images/index/1.png',
				},
				6: {
					text: '更换中',
					color: '#0091ff',
					icon: '/static/images/index/2.png',
				},

				7: {
					text: '已完成',
					color: '#333',
					icon: '/static/images/index/s4d.png',
				},
				9: {
					text: '已关闭',
					color: '#999',
					icon: '',
				},
				8: {
					text: '已驳回',
					color: '#999',
					icon: '',
				},
			},
			statusRescue: {
				2: {
					text: '待开始',
					color: '#16BF99',
					icon: '/static/images/index/1.png',
				},
				3: {
					text: '已出发',
					color: '#F7C800',
					icon: '/static/images/index/3.png'
				},
				4: {
					text: '已到达',
					color: '#FA6400',
					icon: '/static/images/index/6.png',
				},
				5: {
					text: '已救援',
					color: '#999',
					icon: '/static/images/index/4.png',
				},
				6: {
					text: '已撤回',
					color: '#999',
					icon: '',
				},
			},

			loading: false,
			tabIdx: 0,
			list: [],
			total: 0,
			current: 1,
			customDate: '',
			seachForm: {
				// 日期范围 1今天，2近七天，3近30天，4自定义日期
				dateType: 2,
				startTime: '',
				endTime: '',
				userList: [],
				groupId: [],
				memberList: [],
				status: '',
				keyword: '',
				// 计划时间排序 倒序
				planDateSort: 'desc',
				// 完成时间排序 倒序
				planFishDateSort: 'desc',
				createSort: 'desc',
				finishSort: 'desc',
				statusStr: '',
			},
			type: 0,
			csd: {},
			wxCsd: {},
			pjCsd: {},
			allFilter: true,
			showFilter: false,
			dateObj: {
				startTime: '',
				endTime: '',
				value: ''
			},
			dateTemp: {},
			formatTime: formatTime,
			getMonthDate: getMonthDate,
			isCanScroll: true,
			// 选择项目弹窗
			seleShows: false,
			buildingData: [],
			seleState: '',
			preObjs: {}
		};
	},
	async onLoad(os) {
		console.log(os,'os');
		// 0 从详情页 进来,1 从公众号模板消息 //2 从历史工单进来

		this.type = os.type || 0;
		// this.showFilter = true;
		this.tabIdx = os.tabIdx || 0;
		this.tabStateIdx = os.tabStateIdx || 0;
		this.$nextTick(() => {
			this.$refs.filterModel.initModel(this.tabIdx);
		});
		uni.$on('itemUpdate', (res) => {
			this.itemUpdate(res);
		});
		let byCsd = {};
		for (const osKey in os) {
			let arr = ['statusStr','auditTypeStr','userSignatureType','overdueTypeStr'];
			if (arr.includes(osKey)) {
				byCsd[osKey] = os[osKey].split(',').map(item => Number(item));
				if (osKey === 'userSignatureType' && !Array.isArray(os[osKey])) {
					this.seachForm[osKey] = [os[osKey]];
				} else {
					this.seachForm[osKey] = os[osKey];
				}
			}
		}
		if (os.statusStr) {
			if (os.statusStr.length > 1) {
				this.tabStateIdx = 0;
			} else {
				this.tabStateIdx = this.tabList.findIndex(item => item.status == os.statusStr);
			}
		}
		this.preObjs = os;
		// 维修电子围栏触发显示弹窗
		if (os.type == '2' && (os.state == 'STATUS_IN' || os.state == 'STATUS_OUT')) {
			this.tabIdx = 1;
			let multipleArr = (hanleToken('get', 'enclosureData') || []).map(item => item.buildingId);
			let dataListPlus = await this.$store.dispatch('user/getPlanLatitudePlus', multipleArr.join(','));
			let filterArr = dataListPlus.filter(item => item.signType == 1);
			this.seleState = os.state;
			this.seleModelShows(true, filterArr);
			this.handleClickTab(1);
		}
		if (this.userinfo.user_id) {
			if (this.bool) {
				this.initData();
			}
		} else {
			let hasLogin = await this.handleRreshToken();
			if (!hasLogin) {
				uni.navigateTo({
					url: '../login/index'
				});
			}
			this.initData();
		}
		if (this.tabIdx == 0) {
			this.csd = byCsd;
			console.log(byCsd,'byCsd');
		} else if (this.tabIdx == 1) {
			this.wxCsd = {};
		} else {
			this.pjCsd = {};
		}
		this.getList();
	},
	mounted() {
		const query = uni.createSelectorQuery().in(this);
		query.select('.header').boundingClientRect(data => {
			this.headerHeight = data.height;
		}).exec();
	},
	async created() {
		if (uni.getStorageSync('newTop')) {
			this.bool = false;
		}
	},
	onShow() {
		console.log('onShow', this.type);
		// #ifdef H5
		if (this.type == '2') {
			uni.setNavigationBarTitle({ title: '个人工单' });
		}
		// #endif
	},
	onPullDownRefresh() {
		this.handleClickTab(this.tabIdx);
	},
	beforeDestroy() {
		uni.$off('itemUpdate');
	},
	methods: {
		// 更新工单状态
		itemUpdate(item) {
			for (let i = 0; i < this.list.length; i++) {
				if (this.list[i].planId == item.planId) {
					this.list[i].status = item.status;
					break;
				}
			}
		},
		sliceStr(str) {
			if (str.length >= 15) {
				str = str.slice(0, 15) + '...';
			}
			return str;
		},
		showTurnBtn(item) {
			let flag = false;
			// 非年审梯
			if (item.auditType === 1) {
				// 如果是待处理//非年审梯
				if (item.typeStatus === 1 && (!item.timeliness || item.timeliness == '及时')) {
					flag = true;
				}
			} else {
				// 如果是待处理//年审梯
				if (item.typeStatus === 1 && (!item.timeliness || item.timeliness == '及时')) {
					flag = true;
					// 年审梯 已延期特殊延期过 不显示更多按钮
					if (item.planDate) {
						if ((item.deferType === 1 || item.deferType === 5) && new Date(item.planDate.replaceAll('-', '/')).getTime() / 1000 === new Date(dayjs().format('YYYY/MM/DD')).getTime() / 1000) {
							flag = false;
						}
					}
				}
			}
			return flag;
		},
		// 更多操作 年审和非年审跳转
		handleMore(item) {
			if (item.planContentUserVos && item.planContentUserVos.length > 0) {
				let result = item.planContentUserVos.some((it) => it.userId === this.userinfo.user_id);
				if (!result) {
					uni.showModal({
						title: '提示',
						content: '你没有权限操作该任务',
						showCancel: false,
						confirmText: '我知道了',
						success: (res) => {
							if (res.confirm) {
								console.log('用户点击确定');
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});
					return;
				}
			}

			let arr = ['延期保养', '提前保养'];
			// 待开始+未逾期
			if (item.status === 1 && (!item.timeliness || item.timeliness == '及时')) {
				// 年审类型
				if (item.auditType === 2) {
					arr = ['延期保养'];
					// 被特殊年审延期过后
					if (item.deferType === 5 || item.deferType === 1) {
						arr = ['提前保养'];
					}
				}
				// 非年审类型
				if (item.auditType === 1) {
					if (item.planDate) {
						// 小于等于今天任务的日期只显示延期
						if (new Date(item.planDate.replaceAll('-', '/')).getTime() / 1000 <= new Date().getTime() / 1000) {
							arr = ['延期保养'];
						}
					}
				}

				uni.showActionSheet({
					itemList: arr,
					success: async res => {
						let needObj = {
							planId: item.planId,
							buildingAddress: item.buildingName + item.elevatorAddress,
							planCheckName: item.planCheckName,
							planDate: item.planDate,
							auditType: item.auditType
						};
						// 非年审
						if (item.auditType === 1) {
							let str = '';
							// 去延期保养页面
							if (res.tapIndex === 0) {
								str = '/pageModules/yearTrial/calendarEdit?needObj=' + JSON.stringify(needObj) + '&nums=' + 1;
							}
							// 去提前保养页面
							if (res.tapIndex === 1) {
								str = '/pageModules/yearTrial/calendarEdit?needObj=' + JSON.stringify(needObj) + '&nums=' + 2;
							}
							uni.navigateTo({
								url: str
							});
						}
						// 年审
						if (item.auditType === 2) {
							if (res.tapIndex == 0 && arr[0] === '延期保养') {
								uni.navigateTo({
									url: '/pageModules/yearTrial/yearDelay?needObj=' + JSON.stringify(needObj)
								});
							}
							if (res.tapIndex == 0 && arr[0] === '提前保养') {
								uni.navigateTo({
									url: '/pageModules/yearTrial/calendarEdit?needObj=' + JSON.stringify(needObj) + '&nums=' + 3
								});
							}
						}
					},
					fail() { }
				});
			}
		},
		// 计划时间排序切换
		changePlanDateSort() {
			if (this.seachForm.planDateSort == 'asc' || this.seachForm.planDateSort == '') {
				this.seachForm.planDateSort = 'desc';
			} else {
				this.seachForm.planDateSort = 'asc';
			}
			if (this.seachForm.createSort == 'asc' || this.seachForm.createSort == '') {
				this.seachForm.createSort = 'desc';
			} else {
				this.seachForm.createSort = 'asc';
			}
			this.seachForm.finishSort = '';
			this.seachForm.planFishDateSort = '';
			this.goTop();
			this.getList({ statusChange: true });
		},
		// 完成时间排序切换
		changePlanFishDateSort() {
			if (this.seachForm.planFishDateSort == 'asc' || this.seachForm.planFishDateSort == '') {
				this.seachForm.planFishDateSort = 'desc';
			} else {
				this.seachForm.planFishDateSort = 'asc';
			}
			if (this.seachForm.finishSort == 'asc' || this.seachForm.finishSort == '') {
				this.seachForm.finishSort = 'desc';
			} else {
				this.seachForm.finishSort = 'asc';
			}
			this.seachForm.createSort = '';
			this.seachForm.planDateSort = '';
			this.goTop();
			this.getList({ statusChange: true });
		},
		// 状态切换筛选
		chooseTab(item, index) {
			this.goTop();
			if (index == this.tabList.length - 1) {
				this.seachForm.planFishDateSort = '';
			}
			this.csd = {};
			// 清除URL中传入的参数
			this.clearUrlParams();
			this.seachForm.status = item.status;
			this.seachForm.statusStr = item.status;
			this.dateObj.planBeginDate = '';
			this.dateObj.planEndDate = '';
			this.dateObj.startTime = '';
			this.dateObj.endTime = '';
			this.dateObj.value = '';
			this.dateObj.value2 = '';
			this.seachForm.planDateSort = 'desc';

			if ([3, 4, 5].includes(this.tabIdx)) {
				this.seachForm.planDateSort = '';
				this.seachForm.finishSort = '';
				this.seachForm.createSort = 'desc';
				this.seachForm.planStatus = item.status;
			}

			this.$nextTick(() => {
				this.$refs.filterModel.initModel(this.tabIdx);
			});
			this.tabStateIdx = index;
			this.seachForm.planBeginDate = undefined;
			this.seachForm.planEndDate = undefined;
			this.seachForm.endTime = undefined;
			this.seachForm.startTime = undefined;
			this.getList({ statusChange: true });
		},
		goTop() {
			this.scrollGoTop = 1;
			this.$nextTick(() => {
				this.scrollGoTop = 0;
			});
		},
		scroll(e) {
			this.scrollTop = e.target.scrollTop;
		},
		// 滑动切换
		getActIdx(idx) {
			this.tabIdx = idx;
			this.handleClickTab(this.tabIdx);
		},
		// 去我的任务
		toMyTask() {
			uni.navigateTo({
				url: '/pages/home/index?footerIndex=1',
				fail(e) {
					console.log(e);
				},
			});
		},
		scrolltolower() {
			this.getList(this.csd);
		},
		showFilterChange(res) {
			console.log(res, 6666);
			this.isCanScroll = !res;
		},
		...mapActions('user', ['handleRreshToken', 'getRoutes']),
		// 去项目详情
		toProjectDetail(item) {
			console.log(item);
			// type=2 =>是个人工单
			if (this.type == 2) {
				uni.navigateTo({
					url: '/pageModules/projectInfo/detail?id=' + item.buildingId,
				});
			} else {
				return;
			}
		},
		// 获取筛选的东西
		filterd(res) {
			let { choosed, dateObj } = res;
			// let choosedKeys = Object.keys(choosed);
			// 清除URL中传入的参数
			this.clearUrlParams();
			if (choosed.statusStr) {
				this.seachForm.statusStr = '';
				this.seachForm.status = '';
				if (choosed.statusStr.length === 1) {
					this.tabStateIdx = this.tabList.findIndex(item => item.status == choosed.statusStr);
				} else {
					this.tabStateIdx = 0;
				}
			}
			// let obj = {};
			if (this.type == 2) {
				for (const key in res.dateObj) {
					this.seachForm[key] = res.dateObj[key];
				}
				this.dateObj = dateObj;
			}

			this.csd = choosed;
			this.current = 1;
			this.totla = 0;
			this.list = [];

			console.log('筛选完成', res, this.seachForm);
			this.goTop();
			this.getList(choosed);
			// this.$refs.filterModel.initModel(this.tabIdx);
		},
		// 获取筛选框的数据
		getFilterData(res) {
			this.csd = res.choosed;
		},
		// 顶部按钮返回上一页
		handleBack() {
			uni.navigateBack({});
		},
		// aa() {
		// 	console.log('点击了筛选按钮');
		// 	this.showFilter = true;
		// },
		handchange(val, index) {
			this.list[index].usermore = val;
		},
		toNext() {
			uni.navigateBack();
		},
		// 切换时间类型
		filterFuc(res, idx) {
			console.log('filterFuc', res);
			this.filtIdx = idx;
			if (res.id == 10) {
				// 近七天
				const dates = getLastDates(7);
				this.seachForm.startTime = dates.startTime;
				this.seachForm.endTime = dates.endTime;
				this.customDate = '';
				// this.getTotals();
				this.handleClickTab(this.tabIdx);
			}
			if (res.id == 11) {
				// 近30天
				const dates = getLastDates(30);
				this.seachForm.startTime = dates.startTime;
				this.seachForm.endTime = dates.endTime;
				this.customDate = '';
				// this.getTotals();
				this.handleClickTab(this.tabIdx);
			}
			if (res.id == 12) {
				this.selectTimePopup = true;
				return;
			}
		},
		// 初始化数据
		initData() {
			// console.log('初始化页面');
			console.log(this.type, 'type的值');
			// this.seachForm.planStatus = this.type == 0 ? '' : 1;
			if (this.type == 0 || this.type == 1) {
				uni.getStorage({
					key: 'recordFilter',
					success: (res) => {
						console.log(res.data, '缓存的值');

						if (this.type == 1) {
							// 1公众号模板
							this.seachForm.userList = [this.userinfo.user_id];
						} else {
							this.seachForm.userList = res.data.userList;
						}
						this.seachForm.dateType = res.data.filter.dateType;
						this.seachForm.startTime = res.data.filter.startTime;
						this.seachForm.endTime = res.data.filter.endTime;

						if (res.data.filter.dateType == 2) {
							this.filtIdx = 0;
							this.customDate = '';
						} else if (res.data.filter.dateType == 3) {
							this.filtIdx = 1;
							this.customDate = '';
						} else {
							this.filtIdx = 2;
							if (this.seachForm.startTime == this.seachForm.endTime) {
								this.customDate = this.seachForm.startTime.replaceAll('-', '/');
							} else {
								let start = this.seachForm.startTime.split('-');
								let end = this.seachForm.endTime.split('-');
								this.customDate =
                    start[1] + '/' + start[2] + '-' + end[1] + '/' + end[2];
							}
						}
						// console.log(res,this.seachForm,666);
						// this.getTotals();
						this.handleClickTab(this.tabIdx);
					},
				});
			} else {
				// 不走缓存
				this.seachForm.userList = [this.userinfo.user_id];
				this.seachForm.startTime = '';
				this.seachForm.endTime = '';
				// this.getTotals();
				this.handleClickTab(this.tabIdx);
			}
		},

		// 自定义日期
		closeSelectTimePopup(res) {
			if (res) {
				console.log('自定义日期', res);
				let start = '';
				let end = '';

				if (res.indexOf('-') != -1) {
					const timeArr = res.split('-');
					start = timeArr[0].replaceAll('.', '-');
					end = timeArr[1].replaceAll('.', '-');
				} else {
					const time = res.replaceAll('.', '-');
					start = time;
					end = time;
				}
				const nowDay = getNowTime();
				let nowtime = new Date(nowDay).getTime();
				// let starttime = new Date(start).getTime();
				let endtime = new Date(end).getTime();
				if (endtime >= nowtime) {
					console.log('包含今天');
					uni.showToast({
						title: '自定义日期范围须小于今天',
						icon: 'none',
					});
					return;
				}

				this.seachForm.startTime = start;
				this.seachForm.endTime = end;
				this.seachForm.dateType = 4;
				if (this.seachForm.startTime == this.seachForm.endTime) {
					this.customDate = this.seachForm.startTime;
				} else {
					let startD = this.seachForm.startTime.split('-');
					let endD = this.seachForm.endTime.split('-');
					this.customDate = startD[1] + '/' + startD[2] + '-' + endD[1] + '/' + endD[2];
				}
				// this.getTotals();
				this.handleClickTab(this.tabIdx);
			}
			this.selectTimePopup = false;
		},
		// 前往详情页
		toDetail(item) {
			uni.setStorageSync('newTop', this.scrollTop);
			console.log('前往详情页', item);
			if (item.typeStatus == 1) {
				// 保养详情
				let overdueName = item.overdueTypeName;
				let planCheckName = item.planCheckName;
				uni.navigateTo({
					url: `/subpages/workOrders/detail?planId=${item.planId}&elevatorId=${item.elevatorId}&overdueName${overdueName}&planCheckName=${planCheckName}`
				});
			}
			if (item.typeStatus == 2) {
				// 维修详情
				uni.navigateTo({
					url: '/subpages/repair/repariDetail?planId=' + item.planId + '&elevatorId=' + item.elevatorId
				});
			}
			// 救援
			if (item.typeStatus === 3) {
				uni.navigateTo({
					url: `/subpages/rescue/rescueDetail?planId=${item.planId}&elevatorId=${item.elevatorId}`,
				});
			}
			// 配件更换
			if (item.typeStatus == 4) {
				uni.navigateTo({
					url: `/subpages/workOrders/partOrder?planId=${item.planId}&elevatorId=${item.elevatorId}`
				});
			}
			// 事务
			if (item.typeStatus === 5) {
				uni.navigateTo({
					url: `/subpages/repair/affair/affairDetail?planId=${item.planId}&elevatorId=${item.elevatorId}`,
				});
			}
			// 质检
			if (item.typeStatus === 6) {
				uni.navigateTo({
					url: `/subpages/quality/qualityDetail?planId=${item.planId}&elevatorId=${item.elevatorId}`,
				});
			}
		},
		// 查询总数
		// getTotals() {
		// 	// console.log(this.seachForm,"总数获取请求参数");
		// 	orderReordBy({
		// 		current: 1,
		// 		size: 1,
		// 		endTime: this.seachForm.endTime,
		// 		startTime: this.seachForm.startTime,
		// 		// userIds: this.seachForm.userList,
		// 		planStatus: this.seachForm.planStatus
		// 	}).then(res => {
		// 		this.totalData.byOrderCount = res.data.total || 0;
		// 	});
		// 	orderReordWx({
		// 		current: 1,
		// 		size: 1,
		// 		endTime: this.seachForm.endTime,
		// 		startTime: this.seachForm.startTime,
		// 		// userIds: this.seachForm.userList,
		// 		planStatus: this.seachForm.planStatus
		// 		// this.type == 2 ? [4] : []
		// 	}).then(res => {
		// 		this.totalData.wxOrderCount = res.data.total || 0;
		// 	});
		// 	orderReordPj({
		// 		current: 1,
		// 		size: 1,
		// 		endTime: this.seachForm.endTime,
		// 		startTime: this.seachForm.startTime,
		// 		// userIds: this.seachForm.userList,
		// 		planStatus: this.seachForm.planStatus
		// 	}).then(res => {
		// 		this.totalData.pjOrderCount = res.data.total || 0;
		// 	});
		// },
		// 获取列表 param为额外的参数
		getList(params) {
			if (params && params.statusChange) {
				this.list = [];
				this.current = 1;
			}
			if (this.loading || (this.list.length >= this.total && this.total > 0)) {
				uni.hideLoading();
				return;
			}
			let baseParams = {
				current: this.current,
				size: 10,
				endTime: this.seachForm.endTime,
				startTime: this.seachForm.startTime,
				planBeginDate: this.seachForm.planBeginDate,
				planEndDate: this.seachForm.planEndDate,
				beginCreateTime: this.seachForm.planBeginDate,
				endCreateTime: this.seachForm.planEndDate,
				keyword: this.seachForm.keyword,
				status: this.seachForm.status,
				planDateSort: this.seachForm.planDateSort,
				planFishDateSort: this.seachForm.planFishDateSort,
				createTimeSort: this.seachForm.planDateSort,
				finishTimeSort: this.seachForm.planFishDateSort,
			};
			if (this.tabIdx == 0) {
				let arr = ['statusStr','auditTypeStr','userSignatureType','overdueTypeStr'];
				arr.forEach(item => {
					if (this.seachForm[item]) {
						baseParams[item] = this.seachForm[item];
					}
				});
			}
			if (this.seachForm.planDateSort && this.tabIdx == 2) {
				// baseParams = pjBaseParams
				baseParams.createTimeSort = this.seachForm.planDateSort;
				baseParams.planDateSort = undefined;
				baseParams.planFishDateSort = undefined;
				baseParams.finishTimeSort = undefined;
			} else if (this.seachForm.planFishDateSort && this.tabIdx == 2) {
				baseParams.createTimeSort = undefined;
				baseParams.planDateSort = undefined;
				baseParams.planFishDateSort = undefined;
				baseParams.finishTimeSort = this.seachForm.planFishDateSort;
			} else if (this.seachForm.planDateSort) {
				baseParams.createTimeSort = undefined;
				baseParams.planDateSort = this.seachForm.planDateSort;
				baseParams.planFishDateSort = undefined;
				baseParams.finishTimeSort = undefined;
			} else {
				baseParams.createTimeSort = undefined;
				baseParams.planDateSort = undefined;
				baseParams.planFishDateSort = this.seachForm.planFishDateSort;
				baseParams.finishTimeSort = undefined;
			}
			if (this.seachForm.planBeginDate && this.tabIdx == 2) {
				baseParams.beginCreateTime = this.seachForm.planBeginDate;
				baseParams.planBeginDate = undefined;
			} else {
				baseParams.beginCreateTime = undefined;
				baseParams.planBeginDate = this.seachForm.planBeginDate;
			}
			if (this.seachForm.planEndDate && this.tabIdx == 2) {
				baseParams.endCreateTime = this.seachForm.planEndDate;
				baseParams.planEndDate = undefined;
			} else {
				baseParams.endCreateTime = undefined;
				baseParams.planEndDate = this.seachForm.planEndDate;
			}
			if ([3, 4, 5].includes(this.tabIdx)) {
				baseParams.typeStatus = [5, 6, 3][this.tabIdx - 3];
				baseParams.createBeginTime = this.seachForm.planBeginDate;
				baseParams.createEndTime = this.seachForm.planEndDate;
				baseParams.finishBeginTime = this.seachForm.startTime;
				baseParams.finishEndTime = this.seachForm.endTime;
				baseParams.planStatus = this.seachForm.planStatus;
				delete baseParams.keyword;
				baseParams.keyWord = this.seachForm.keyword;
				baseParams = removeEmpty(baseParams);

				if (this.seachForm.createSort) {
					delete baseParams.finishSort;
					delete baseParams.planDateSort;
					// this.seachForm.planDateSort = ''
					// this.seachForm.finishSort = ''
					baseParams.createSort = this.seachForm.createSort;
				} else if (this.seachForm.finishSort) {
					delete baseParams.createSort;
					delete baseParams.planDateSort;
					// this.seachForm.planDateSort = ''
					// this.seachForm.createSort = ''
					baseParams.finishSort = this.seachForm.finishSort;
				}
			}

			this.loading = true;
			const queList = [orderReordBy, orderReordWx, orderReordPj, getUserWorksPlan];
			let tindex = [3, 4, 5].includes(this.tabIdx) ? 3 : this.tabIdx;
			queList[tindex](
				params ? { ...params, ...baseParams, status: params.status ? params.status : baseParams.status } : { ...baseParams }
			)
				.then((res) => {
					const records = res.data.records || [];
					for (var i = 0; i < records.length; i++) {
						records[i].usermore = false;
						if (records[i].partsName) {
							const parts = records[i].partsName.split('&amp;&amp;');
							records[i].parts = parts[parts.length - 1];
						}

						for (var j = 0; j < records[i].planContentUserVos.length; j++) {
							records[i].planContentUserVos[j].signInfo = JSON.parse(
								records[i].planContentUserVos[j].signInfo || '{}'
							);
						}
						if (records[i].planContentUserVos) {
							records[i].planContentUserVos = records[
								i
							].planContentUserVos.sort(this.userSort);
						}
					}
					this.total = res.data.total;
					this.list.push(...records);
					this.current++;
					uni.hideLoading();
					uni.stopPullDownRefresh();
					this.loading = false;
				})
				.catch(() => {
					uni.hideLoading();
					uni.stopPullDownRefresh();
					this.loading = false;
				});
		},
		userSort(a, b) {
			if (a.signUser && a.signUser.isPlanStatus && !b.signUser.isPlanStatus) {
				return -1;
			} else {
				return 1;
			}
		},
		// 切换导航栏
		handleClickTab(idx) {
			this.tabStateIdx = 0;
			// 清除URL中传入的参数
			// this.clearUrlParams();
			this.seachForm.status = '';
			this.seachForm.keyword = '';
			this.seachForm.planDateSort = 'desc';
			this.seachForm.planFishDateSort = '';
			this.seachForm.planBeginDate = undefined;
			this.seachForm.planEndDate = undefined;
			this.seachForm.endTime = undefined;
			this.seachForm.startTime = undefined;
			this.seachForm.planStatus = '';
			this.seachForm.createSort = 'desc';
			this.seachForm.finishSort = '';
			console.log('维修电子围栏触发显示弹窗333', idx, this.loading);
			if (this.loading) {
				return;
			}
			uni.showLoading({
				title: '加载中',
				mask: true,
			});
			this.tabIdx = idx;
			switch (idx) {
			case 0:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '待开始',
						status: 1
					},
					{
						name: '进行中',
						status: 2
					},
					{
						name: '已提交',
						status: 3
					},
					{
						name: '维保签字',
						status: 5
					},
					{
						name: '已完成',
						status: 4
					}
				];
				break;
			case 1:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '待开始',
						status: 2
					},
					{
						name: '进行中',
						status: 3
					},
					{
						name: '已完成',
						status: 4
					},
					{
						name: '已关闭',
						status: 7
					}
				];
				break;
			case 2:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '待更换',
						status: 5
					},
					{
						name: '更换中',
						status: 6
					},
					{
						name: '已完成',
						status: 7
					}
				];
				break;
			case 3:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '待开始',
						status: 2
					},
					{
						name: '进行中',
						status: 3
					},
					{
						name: '已完成',
						status: 4
					}
				];
				break;
			case 4:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '待开始',
						status: 2
					},
					{
						name: '进行中',
						status: 3
					},
					{
						name: '已完成',
						status: 4
					}
				];
				break;
			case 5:
				this.tabList = [
					{
						name: '全部',
						status: ''
					},
					{
						name: '已出发',
						status: 3
					},
					{
						name: '已到达',
						status: 4
					},
					{
						name: '已救援',
						status: 5
					}
				];
				break;
			}
			this.list = [];
			this.seachForm.keyword = '';
			if (this.type == 2) {
				this.seachForm.startTime = '';
				this.seachForm.endTime = '';
			}

			this.current = 1;
			this.total = 0;

			// this.getTotals();
			this.getList();
			this.csd = {};
			this.dateObj.planBeginDate = '';
			this.dateObj.planEndDate = '';
			this.dateObj.startTime = '';
			this.dateObj.endTime = '';
			this.dateObj.value = '';
			this.dateObj.value2 = '';
			this.$nextTick(() => {
				this.$refs.filterModel.initModel(idx);
				// this.$refs.filterModel.reset();
			});
			this.goTop();
			// console.log('回到顶部');
		},
		// 搜索
		handleReSet() {
			this.goTop();
			// 清除URL中传入的参数
			this.clearUrlParams();
			this.getList({ statusChange: true });
		},

		// app端消息条件满足显示弹框
		seleModelShows(status = false, arr = []) {
			this.seleShows = status;
			this.buildingData = arr;
		},
		// 现在项目签到签退
		selectChecd(arr) {
			console.log('现在项目签到签退', arr);
			let actsObj = arr.find(item => item.acts) || {};
			if (!actsObj.acts) {
				uni.showToast({
					title: '请选择项目',
					icon: 'none',
					mask: true,
				});
				return;
			}
			// let data = {
			// 	signType: 1,
			// 	useLastImg: true,
			// 	orderType: 2,
			// };
			// if(this.preObjs.state === 'STATUS_IN'){
			// 	data.signType = 1;
			// }
			// if(this.preObjs.state === 'STATUS_OUT'){
			// 	data.signType = 2;
			// }
			// uni.setStorage({
			// 	key: 'signObj',
			// 	data,
			// });
			// uni.navigateTo({
			// 	url: `/pages/sign/index?planId=${this.preObjs.planId}&elevatorId=${this.preObjs.elevatorId}`,
			// });
			uni.navigateTo({
				url: '/subpages/repair/repariDetail?planId=' + actsObj.planId + '&elevatorId=' + actsObj.elevatorId,
			});
			this.$refs.buidingEleCom.$refs.popupr.close();
		},
		// 添加清除URL参数的方法
		clearUrlParams() {
			// 清除从URL中获取的参数
			const urlParams = ['statusStr', 'auditTypeStr', 'userSignatureType', 'overdueTypeStr'];
			urlParams.forEach(param => {
				if (this.seachForm[param]) {
					this.seachForm[param] = '';
				}
			});
		}
	},
};
</script>
<style lang="scss">
@import '@/components/tagsComponents/iconfont.css';

page {
  background-color: #f3f6f8;
}
</style>
<style lang="scss" scoped>
.wrap {
  overflow-y: auto;
}

.Rtag {
  padding: 0rpx 8rpx;
  font-size: 24rpx;
  border-radius: 4rpx;
  border: 2rpx solid;
  white-space: nowrap;
  margin-left: 6rpx;
  color: #E02020;
  border-color: #E02020;
  font-weight: normal
}

.plan-turn {
  margin-left: 8rpx;
  font-size: 12px;
  text-align: center;
  color: #0091ff;
  width: 52px;
  height: 16px;
  background: #dcf0ff;
  border-radius: 2px;
  line-height: 16px;
  padding: 0 4rpx;
  font-weight: 400;
}

.header-icon {
  width: 22rpx;
  line-height: 20rpx;
  display: flex;
  flex-direction: column;
  margin-left: 8rpx;
  justify-content: center;
  margin-bottom: 6rpx;

  .iconfont {
    font-size: 8px;
    height: 8px;
  }
}

.planTime {
  display: flex;
  padding: 20rpx;
  align-items: center;
  background-color: #f3f6f8;
  justify-content: space-between;

  .left {
    color: #666;
    font-size: 26rpx;
    flex: 1;

    text {
      color: #0091ff;
    }
  }

  .right {
    display: flex;

    .plan {
      display: flex;
    }

    .end {
      margin-left: 20rpx;
      display: flex;
    }

  }
}

.scroll-x {
  white-space: nowrap;
  width: calc(100% - 20rpx);

  ::-webkit-scrollbar {
    display: none;
    width: 0 !important;
    height: 0 !important;
    -webkit-appearance: none;
    background: transparent;
    color: transparent;
  }
}

.tabList {
  display: flex;
  padding: 20rpx 0;

  .titleTab {
    height: 44rpx;
    border-radius: 22rpx;
    padding: 0 20rpx;
    margin-left: 20rpx;
    background-color: #F3F6F8;
    color: #666;
    font-size: 26rpx;
    line-height: 44rpx;
  }

  .activeItem {
    background-color: #DCF0FF;
    color: #0091FF;
    font-size: 26rpx;
  }

}

.none-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 250rpx;
  padding-top: 120rpx;

  .img {
    image {
      width: 64rpx;
      height: 64rpx;
    }
  }

  .text {
    width: 100%;
    color: #999999;
    font-size: 26rpx;
  }
}

.header {
  background-color: #fff;

  .tabs {
    width: 96%;
    padding: 0 2%;
    background-color: #ffffff;
    display: flex;
    //    position: sticky;
    // z-index: 99999;
    border-bottom: 2rpx #eee solid;

    &-item {
      height: 84rpx;
      line-height: 83rpx;
      margin: 0 20rpx;
      font-size: 26rpx;
      font-weight: 400;
      border-bottom: 4rpx solid #fff;
      color: #93b1c7;
      transition: 0.4s all;
    }

    .act {
      color: #0091ff;
      // font-weight: bold;
      // height: 60rpx;
      // box-sizing: border-box;
      // padding: 16rpx 20rpx;
      border-color: #0091ff;
      font-size: 30rpx;
    }
  }

  .tips {
    background: #f3f6f8;
    padding: 0 20rpx;
    font-size: 24rpx;
    display: flex;
    justify-content: space-between;
    color: #666;

    view {
      padding: 20rpx 0;
    }

    view:nth-child(2) {
      display: flex;
      flex: 1;
      justify-content: flex-end;
    }
  }
}

.fitlerBox {
  background: #ffffff;
  display: flex;
  align-items: center;
  padding: 20rpx;

  .left {
    border-radius: 8rpx;
    display: flex;
    align-items: center;

    /deep/ .uni-searchbar {
      padding: 0;
    }

    /deep/ .uni-searchbar__box {
      width: 600rpx;
      height: 64rpx;
      justify-content: flex-start;
      font-size: 26rpx;
      color: #ccc;
      background-color: #f6f6f6;
      border: 0;
      border-radius: 8rpx;
    }

    /deep/ .uni-icons {
      width: 40rpx;
      height: 40rpx;
    }

    /deep/ .uni-searchbar__text-placeholder {
      margin: 0;
    }

    /deep/ .uni-searchbar__box-search-input {
      border: 0;
      padding: 0;
    }

    input {
      font-size: 26rpx;
      height: 36rpx;
      padding-left: 28rpx;
      width: 600rpx;
      box-sizing: border-box;
    }

    image {
      width: 40rpx;
      height: 40rpx;
    }
  }

  .right {
    display: flex;
    flex: 1;
    align-items: center;
    font-size: 26rpx;
    color: #333;
    justify-content: flex-end;

    image {
      width: 26rpx;
      height: 26rpx;
    }
  }
}

.line {
  height: 2rpx;
  background: #eee;
}

.records {
  width: 100%;
  color: #333;
  min-height: 1000rpx;

  &-item {
    width: calc(100% - 40rpx);
    margin: 20rpx;
    background-color: #fff;
    border-radius: 8rpx;

    &-head {
      display: flex;
      color: #333333;
      font-size: 26rpx;
      justify-content: space-between;
      align-items: baseline;
      border-bottom: 2rpx solid #eeeeee;
      padding: 20rpx;

      .buildding {
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex: 1;

        image {
          width: 32rpx;
          height: 32rpx;
          margin-right: 7rpx;
          padding-top: 5rpx;
        }

        view {
          flex: 1;
          line-height: 38rpx;
        }
      }

      .status {
        display: flex;
        justify-content: flex-end;
        align-items: flex-start;
        width: max-content;

        image {
          width: 32rpx;
          padding-top: 3rpx;
          height: 32rpx;
          margin-right: 7rpx;
        }
      }
    }

    &-content {
      padding: 24rpx 20rpx;
      display: flex;
      align-items: center;
      padding-bottom: 12rpx;
      flex-direction: column;

      .name {
        font-size: 32rpx;
        font-weight: bold;
        width: 100%;

        text:nth-child(1) {
          vertical-align: middle;
        }
      }

      .intro {
        width: 100%;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: flex-start;
      }

      .left {
        flex: 1;

        .tags {
          display: flex;
          flex-wrap: wrap;
          justify-content: flex-start;
          align-items: baseline;
          font-size: 26rpx;
          color: #666;
          margin: 16rpx 0;

          .tag {
            border: 2rpx solid #cccccc;
            border-radius: 20rpx;
            font-size: 24rpx;
            padding: 0rpx 13rpx;
            margin: 8rpx 0;
            margin-right: 12rpx;
          }

          .noBorder {
            border: none
          }

        }

        .tags_desc {
          display: flex;
          font-size: 26rpx;
          color: #666;

          .lable_tit {
            white-space: nowrap;
          }

          .lable_desc {
            width: 400rpx;
            margin-left: 16rpx;
            margin-bottom: 16rpx;
          }
        }

        .labs {
          display: flex;
          flex-wrap: wrap;
          justify-content: flex-start;
          align-items: baseline;

          .lab {
            font-size: 24rpx;
            color: #e02020;
            background: #ffe3e3;
            padding: 0rpx 13rpx;
            border-radius: 4rpx;
            margin: 8rpx 0;
            margin-right: 8rpx;
          }
          .red {
            color: #e02020;
            background: #ffe3e3;
          }
          .yellow {
            color: #fa6400;
            background: #ffefe3;
          }
          .blue {
            color: #0091ff;
            background: #dcf0ff;
          }
        }
      }

      .right {
        width: 74px;

        &-member {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          flex-wrap: wrap;
          margin: 16rpx 0;
        }

        .menber {
          display: flex;
          flex-direction: row;
          justify-content: center;
          align-items: center;
          font-size: 20rpx;
          width: 48rpx;
          height: 48rpx;
          border-radius: 50%;
          background-color: #0091ff;
          color: #fff;
          margin-left: 4rpx;
        }

        image {
          width: 25rpx;
          height: 25rpx;
          margin-left: 5rpx;
          transition: 0.3s all;
        }
      }

      .userlist {
        &-item {
          display: flex;
          align-items: center;
          width: 180rpx;
          margin-bottom: 17rpx;

          .menber {
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 20rpx;
            width: 48rpx;
            height: 48rpx;
            border-radius: 50%;
            background-color: #0091ff;
            color: #fff;
            margin-left: 4rpx;
            margin-right: 14rpx;
          }

          &-name {
            font-size: 24rpx;
            color: #333;
            overflow: hidden;
            flex: 1;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }

        &-item:last-child {
          margin-bottom: 0;
        }
      }
    }

    &-bottom {
      padding: 20rpx;
      border-top: 2rpx solid #eeeeee;
      color: #999999;
      font-size: 24rpx;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .handle {
        // box-sizing: border-box;
        // display: flex;
        // justify-content: flex-end;
        // align-items: center;

        .handle_btn {
          margin-right: auto;
          height: 36rpx;
          padding: 0 20rpx;
          border: 2rpx solid #cccccc;
          border-radius: 4rpx;
          color: #333;
          font-size: 24rpx;
          display: flex;
          align-items: center;
        }
      }
    }
  }
}

.more {
  width: 100%;
  padding: 30rpx 0;
  text-align: center;
  color: #999999;
  font-size: 24rpx;
}
</style>
